<div class="uk-grid">
    <div class="uk-width-1-4@l uk-width-1-2@m uk-width-1-1@s">
        <div class="uk-card uk-card-small uk-card-default dux-stat-widget">
            <i class="media-icon  red fa fa-desktop"></i>
            <div class="media-body">
                <h1 class="title">{intval($sumStats.web)}</h1>
                <p class="grey-text">电脑访问</p>
            </div>
        </div>
    </div>
    <div class="uk-width-1-4@l uk-width-1-2@m uk-width-1-1@s">
        <div class="uk-card uk-card-small uk-card-default dux-stat-widget">
            <i class="media-icon   blue fa fa-wifi"></i>
            <div class="media-body">
                <h1 class="title">{intval($sumStats.mobile)}</h1>
                <p class="grey-text">移动访问</p>
            </div>
        </div>
    </div>
    <div class="uk-width-1-4@l uk-width-1-2@m uk-width-1-1@s">
        <div class="uk-card uk-card-small uk-card-default dux-stat-widget">
            <i class="media-icon  orange fa fa-cube"></i>
            <div class="media-body">
                <h1 class="title">{intval($sumStats.api)}</h1>
                <p class="grey-text">API访问</p>
            </div>
        </div>
    </div>
    <div class="uk-width-1-4@l uk-width-1-2@m uk-width-1-1@s">
        <div class="uk-card uk-card-small uk-card-default dux-stat-widget">
            <i class="media-icon  green fa fa-book"></i>
            <div class="media-body">
                <h1 class="title">{$contentStats}</h1>
                <p class="grey-text">内容数量</p>
            </div>
        </div>

    </div>
</div>

<div class="uk-grid">
    <div class="uk-width-2-3@l">
        <div class="uk-card uk-card-small uk-card-default dux-panel">
            <div class="uk-card-header">
                访问统计
            </div>
            <div class="uk-card-body uk-padding-small">
                <form class="uk-form uk-form-inline" action="{url()}" method="get">
                    <div class="uk-form-group">
                        <input type="text" name="start_date" value="{$pageMaps.start_date ? $pageMaps.start_date : date('Y-m-d', strtotime('-7 day'))}" data-dux="form-date" placeholder="开始日期" readonly>
                    </div>
                    <div class="uk-form-group">
                        <input type="text" name="stop_date" value="{$pageMaps.stop_date ? $pageMaps.stop_date : date('Y-m-d')}"  data-dux="form-date" placeholder="截止日期" readonly>
                    </div>
                    <div class="uk-form-group">
                        <button type="submit" class="uk-button uk-button-primary">查看</button>
                    </div>
                </form>
            </div>
            <div class="uk-card-body">
                <canvas id="stats-web" height="405"></canvas>
            </div>
        </div>

    </div>
    <div class="uk-width-1-3@l">
        <div class="uk-card uk-card-small uk-card-default dux-profile-widget">
            <div class="profile-bg teal lighten-1"></div>
            <img src="{$sysUserInfo.avatar}" class="profile-avatar" alt="img">
            <div class="profile-title">{$sysUserInfo.nickname} ({$sysUserInfo.role_name})</div>
            <p class="profile-text">于 {date('Y年m月d日 H:i', $sysUserInfo.login_time)} 登录</p>
        </div>
        <br>
        <div class="uk-card uk-card-small uk-card-default dux-panel">
            <div class="uk-card-header">授权信息</div>
            <div class="uk-card-body uk-padding-small" id="licence">

                <div class="uk-padding uk-text-center">
                    <i class="fa fa-spinner fa fa-pulse"></i>
                    授权信息获取中...
                </div>

            </div>
        </div>
    </div>
</div>

<div class="uk-grid">
    <div class="uk-width-1-2@l">
        <div class="uk-card uk-card-small uk-card-default dux-panel">
            <div class="uk-card-header">系统环境</div>
            <div class="uk-card-body uk-padding-small">
                <table class="uk-table  uk-table-responsive  uk-table-striped">
                    <tbody>
                    <tr>
                        <td>操作系统</td>
                        <td colspan="3"><?PHP echo PHP_OS;  ?></td>
                    </tr>
                    <tr>
                        <td>WEB环境</td>
                        <td>{$_SERVER ['SERVER_SOFTWARE']} / PHP {phpversion()}</td>
                        <td>数据库</td>
                        <td><?php $config = \dux\Config::get('dux.use_data'); echo $config['type']; ?></td>
                    </tr>
                    <tr>
                        <td>服务器IP</td>
                        <td>{$_SERVER['SERVER_ADDR']}</td>
                        <td>上传限制</td>
                        <td><?PHP echo get_cfg_var ("upload_max_filesize")?get_cfg_var ("upload_max_filesize"):"不允许上传附件"; ?></td>
                    </tr>
                    <tr>
                        <td>Redis支持</td>
                        <td><?php echo class_exists('Redis') ? '<span class="uk-text-success">支持</span>' : '<span class="uk-text-danger">不支持</span>'; ?></td>
                        <td>Curl支持</td>
                        <td><?php echo function_exists('curl_init') ? '<span class="uk-text-success">支持</span>' : '<span class="uk-text-danger">不支持</span>'; ?></td>
                    </tr>
                    <tr>
                        <?php $config = \dux\Config::get('dux.use'); ?>
                        <td>日志状态</td>
                        <td><?php echo $config['log'] ? '<span class="uk-text-success">开启</span>' : '<span class="uk-text-warning">关闭</span>'; ?></td>
                        <td>调试状态</td>
                        <td><?php echo $config['debug'] ? '<span class="uk-text-success">开启</span>' : '<span class="uk-text-warning">关闭</span>'; ?></td>
                    </tr>
                    <tr>
                        <td>屏蔽函数</td>
                        <td colspan="3"><?php echo get_cfg_var( "disable_functions")?get_cfg_var( "disable_functions"): "无" ; ?></td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <div class="uk-width-1-2@l">
        <div class="uk-card uk-card-small uk-card-default dux-panel">
            <div class="uk-card-header">程序信息</div>
            <div class="uk-card-body uk-padding-small">
                <table class="uk-table  uk-table-middle uk-table-divider uk-table-responsive  uk-table-striped ">
                    <tbody>
                    <tr>
                        <td>程序版本</td>
                        <td>{$verInfo.ver} ({$verInfo.date})</td>
                    </tr>
                    <tr>
                        <td>框架版本</td>
                        <td><?php echo VERSION; ?> (<?php echo VERSION_DATE; ?>)</td>
                    </tr>
                    <tr>
                        <td>开发支持</td>
                        <td>{$useInfo.team}</td>
                    </tr>
                    <tr>
                        <td>支持网站</td>
                        <td><a href="{$useInfo.home}" target="_blank">{$useInfo.home}</a></td>
                    </tr>
                    <tr>
                        <td>客服电话</td>
                        <td>
                            {$useInfo.tel}
                        </td>
                    </tr>
                    <tr>
                        <td>客服QQ</td>
                        <td>{$useInfo.qq}</td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="licence-tpl">
    <table class="uk-table  uk-table-responsive  uk-table-striped">
        <tbody>
        {{# if(d.domain){ }}
        <tr>
            <td>授权域名</td>
            <td>{{ d.domain }}</td>
        </tr>
        <tr>
            <td>授权状态</td>
            <td>
                <span class="uk-text-success">已授权</span>
                {{ d.type_name }}
            </td>
        </tr>
        <tr>
            <td>授权信息</td>
            <td>{{ d.name }} - {{ d.tel }}</td>
        </tr>
        <tr>
            <td>到期时间</td>
            <td>{{ d.date }}</td>
        </tr>
        {{# }else{ }}

        <tr>
            <td>获取授权</td>
            <td>{{d.message}}</td>
        </tr>
        {{# } }}

        <tr>
            <td>更新检测</td>
            <td>
                {{# if(d.ver_status){ }}
                <span class="badge badge-success">{{d.ver}}</span>
                <a href="{url('system/update/index')}" class="uk-text-danger">现在更新</a>
                {{# }else{ }}
                <a href="javscript:;" class="uk-text-success">暂无更新</a>
                {{# } }}
            </td>
        </tr>
        </tbody>
    </table>
</script>
<script>
    Do('base', 'chart', 'tpl', function () {

        app.ajax({
            url : '{url("licence")}',
            type : 'get',
            success : function (data) {
                var tpl = $('#licence-tpl').html();
                laytpl(tpl).render(data, function(html){
                    $('#licence').html(html);
                });

            },
            error : function (msg) {
                var html = '<div class="uk-padding uk-text-center uk-text-danger">'+msg+'</div>';
                $('#licence').html(html);
            }
        });

        function showData() {
            var canvas = $('#stats-web').get(0);
            var ctx = canvas.getContext("2d");
            new Chart(ctx, {
                type: 'line',
                data: {
                    labels: {json_encode($statsData.labels)},
            datasets: {json_encode($statsData.datasets)}
        },
            options: {
                response: true,
                    maintainAspectRatio : false
            }
        });
        }
        showData();

    });
</script>